<%@page import="org.apache.commons.beanutils.BeanUtils"%>
<%@page import="org.apache.commons.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>通讯录</title>
<!-- for-mobile-apps -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords"
	content="Dazzling Multi Forms Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template, 
Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
<script type="application/x-javascript">
	
	 addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);
		function hideURLbar(){ window.scrollTo(0,1); } 

</script>
<!-- //for-mobile-apps -->
<link href="/cd/css/style.css" rel="stylesheet" type="text/css"
	media="all" />
<link rel="/cd/stylesheet" href="css/flexslider.css" type="text/css"
	media="screen" property="" />
<!-- js -->
<script src="/cd/js/jquery-2.2.3.min.js"></script>
<!-- //js -->
<!-- <link href="//fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet"> -->
</head>
<jsp:useBean id="user" class="com.cd.model.User" scope="session"></jsp:useBean>
<%
	if (session.getAttribute("user") != null) {
		try {
			BeanUtils.copyProperties(user, session.getAttribute("user"));
			/* if (user.getUsername().length() == 0) {
				user.setNickname("");
			} */
			if(user.getUsername().equals(user.getNickname())){
				user.setNickname("");
			}

		} catch (Exception e) {
			//e.printStackTrace();
		}
		System.out.println("session中的user值为: " + user.toString());
	}
%>
<body>
	<div class="main">
		<!-- <h1>通讯录</h1>
		<p class="agile_para">软件1501 梅王清 1512190328</p> -->
		<div class="w3_agile_main_grids">
			<section class="slider">
			<div class="flexslider">
				<ul class="slides">
					<div class="agileits_w3layouts_main_grid">
						<h3>注册</h3>
						<form action="RegisterServlet" method="post">
							<span> <label>用户名</label> <input name="username"
								id="username" type="text" placeholder="请输入用户名"
								value=<%=user.getUsername()%>>
							</span> 
							<span> <label>密码</label> <input name="password"
								id="password" type="password" placeholder="请输入密码" value=<%=user.getPassword()%>>
							</span> 
							<span> <label>确认密码</label> <input name="repassword"
								id="repassword" type="password" placeholder="请再次输入密码" value=<%=user.getPassword()%>>
							</span> 
							<span> <label>昵称</label> <input name="nickname"
								id="nickname" type="text" placeholder="若为空则为用户名"
								value=<%=user.getNickname()%>>
							</span> 
							<span> <label>性别</label> 
							<select name="sex">
									<option value="未知">未知</option>
									<%
										if (user.getSex().equals("男")) {
											out.print("<option value='男' selected='selected'>男</option>");
										} else {
											out.println("<option value='男'>男</option>");
										}
									%>
									<%
										if (user.getSex().equals("女")) {
											out.print("<option value='女' selected='selected'>女</option>");
										} else {
											out.println("<option value='女'>女</option>");
										}
									%>
									<!-- <option value="女">女</option> -->
							</select>
							
							</span> <span> <label>手机号码</label> <input name="number"
								type="text" placeholder="请输入手机号码" value=<%=user.getNumber()%>>
							</span> <span> <label>e-mail</label> <input name="email"
								id="email" type="text" placeholder="请输入邮箱"
								value=<%=user.getEmail()%>>
							</span>

							<div class="w3_agileits_submit">
								<input id="submit" type="submit" value="提交"> <input
									type="reset" value="重置">
							</div>
						</form>
					</div>
				</ul>
			</div>
			</section>
		</div>
	</div>

</body>
<!-- <script>
$(document).ready(
$("#addPerson").click(function(){
var number = $("#number").val();
if(number==""||number==null){
alert("请输入电话号码");
return;
}
var name = $("#name").val();
var sex = $("#sex").val();
//alert(sex);
var address = $("#address").val();
var email = $("#email").val();
var person = {};
person["number"] = number;
person["name"] = name;
person["sex"] = sex;
person["address"] = address;
person["email"] = email;
//alert(JSON.stringify(person));
$.ajax({
type:"POST",
url:"addPerson",
data:JSON.stringify(person),
contentType:"application/json",
dataType:"Json",
success:function(data){if(data.code==200) alert("添加成功");
if(data.code==500)alert("该电话号码已存在,添加失败");},
error:function(){alert("服务器出错");}
});
})



);

function addPerson(){

var number = $("#number").val();
if(number==""||number==null){
alert("请输入电话号码");
return;
}
var name = $("#name").val();
var sex = $("#sex").val();
//alert(sex);
var address = $("#address").val();
var email = $("#email").val();
var person = {};
person["number"] = number;
person["name"] = name;
person["sex"] = sex;
person["address"] = address;
person["email"] = email;
//alert(JSON.stringify(person));
$.ajax({
type:"POST",
url:"addPerson",
data:JSON.stringify(person),
contentType:"application/json",
dataType:"Json",
success:function(data){if(data.code==200){ alert("添加成功");window.location.href="index.jsp"}
if(data.code==500)alert("该电话号码已存在,添加失败");},
error:function(){alert("服务器出错");}
});


return false;
}


</script> -->
</html>